<?php
	class xeploaihkdb
	{
		public function Add($MaHocSinh, $HocKy, $NamHoc, $DiemTBHK, $MaHanhKiem, $XepLoaiHK)
		{
			$sql = "INSERT INTO `tbl_xeploaihk`(`MaHocSinh`, `HocKy`, `NamHoc`, `DiemTBHK`, `MaHanhKiem`, `XepLoaiHK`) 
			VALUES ('$MaHocSinh', '$HocKy', '$NamHoc', $DiemTBHK, $MaHanhKiem, '$XepLoaiHK')";
			$data = new dataservice();
			return $data->ExecuteNonQuery($sql);
		}
		
		
		public function Update($MaHocSinh, $HocKy, $NamHoc, $DiemTBHK, $MaHanhKiem, $XepLoaiHK)
		{
			$sql = " UPDATE  `tbl_xeploaihk` 
			 SET DiemTBHK = $DiemTBHK,
				 MaHanhKiem = $MaHanhKiem,
				 XepLoaiHK = '$XepLoaiHK'			
			WHERE MaHocSinh = '$MaHocSinh' AND HocKy = '$HocKy' AND NamHoc = '$NamHoc'  "; 
			$data = new dataservice();
			return $data->ExecuteNonQuery($sql);
		}
	
	
		public function GetList($MaHocSinh, $HocKy, $NamHoc)
		{
			$sql = " SELECT * FROM  `tbl_xeploaihk`,`tbl_hocsinh`,`tbl_hanhkiem`, `tbl_namhoc` WHERE  tbl_xeploaihk.MaHocSinh = tbl_hocsinh.MaHocSinh AND tbl_xeploaihk.MaHanhKiem = tbl_hanhkiem.MaHanhKiem AND tbl_xeploaihk.NamHoc = tbl_namhoc.NamHoc AND tbl_xeploaihk.HocKy=tbl_namhoc.HocKy ";
			if($MaHocSinh!="")
				$sql .= " AND tbl_xeploaihk.MaHocSinh = '$MaHocSinh' ";			
			if($HocKy!="")
				$sql .= " AND tbl_xeploaihk.HocKy = '$HocKy' ";
			if($NamHoc!="")
				$sql .= " AND tbl_xeploaihk.NamHoc = '$NamHoc' ";			
			$data = new dataservice();
			return $data->ExecuteQuery($sql);
		}
		
		
	}
?>